package base.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class ProxyHandler implements InvocationHandler{

	private Object target;
	
	DogInterceptor dog=new DogInterceptor();
	
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		
		Object result=null;
		
		if(method.getName().equals("info")){
			dog.method1();
			result=method.invoke(target, args);
			dog.method2();
		}else{
			result=method.invoke(target, args);
		}
		
		return result;
	}
	
	public Object getTarget() {
		return target;
	}

	public void setTarget(Object target) {
		this.target = target;
	}
}
